package syntaxclass;

import java.util.LinkedList;
import java.util.List;

import polyglot.ast.Expr;
import polyglot.ast.Node;
import polyglot.ast.NodeFactory;
import polyglot.ast.Stmt;
import polyglot.ast.Term;
import polyglot.ext.jl.ast.Stmt_c;
import polyglot.ext.jl.parse.Name;
import polyglot.util.Position;
import polyglot.util.TypedList;
import polyglot.visit.CFGBuilder;
import xaj.ast.XAJNodeFactory;
import xaj.ast.XAJOps;



public class Signal extends Stmt_c implements XAJOps, Stmt {
	
	private Name name;
	
	public Signal(Position pos, Name name) {
		super(pos);
		this.name = name;
	}
	
	@Grammar extends statement {
		Signal ::= "signal" id = simple_name ";"
		    {
			  RESULT = new Signal(parser.pos(id), id);
			};
	}
	
	public Node desugar(/*Context ct,*/ NodeFactory ft) {
		XAJNodeFactory nf = (XAJNodeFactory) ft;		
		List list = new TypedList(new LinkedList(), Expr.class, false);
		Stmt stm = nf.Eval(position(), nf.Call(position(), name.toExpr(), "signal", list));			
		return stm;
	}

	public List acceptCFG(CFGBuilder v, List succs) {
		// TODO Auto-generated method stub
		return null;
	}

	public Term entry() {
		// TODO Auto-generated method stub
		return null;
	}
}